home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part1 / 1503 < prev    next >
Encoding:
Text File  |  1996-08-05  |  1.7 KB  |  54 lines

  1. Path: news.iag.net!news
  2. From: jatmon@iag.net (John R Buchan)
  3. Newsgroups: comp.lang.c
  4. Subject: Re: Splitting String ?
  5. Date: 14 Jan 1996 20:07:11 GMT
  6. Organization: Internet Access Group, Orlando, Florida
  7. Message-ID: <4dbnpf$47c@news.iag.net>
  8. References: <DL3u9M.9xt@rci.ripco.com>
  9. NNTP-Posting-Host: pm3-orl13.iag.net
  10. X-Newsreader: WinVN 0.99.7
  11.  
  12. In article <DL3u9M.9xt@rci.ripco.com>, mambuhl@ripco.com says...
  13. ->
  14. ->hakola@cadmail.hut.fi (Petri Hakola) in
  15. -><HAKOLA.96Jan12151128@jung.hut.fi> asks:
  16. ->
  17. ->
  18. ->>        Have I missed something (again:) or why doesn't this code
  19. ->>        work? I should split dos-a-like-filename and add new postfix
  20. ->>        instead of old one (i.e. DATA.TXT --> DATA.UPD  It seems to
  21. ->>        work correctly if the filename has an old postfix, but if
  22. ->>        there isn't one start won't return what it should.
  23. ->
  24. ->>                                                        - P -
  25. ->
  26. ->I may have missed something here, too.  Your code [at EOM] seems to work
  27. ->for me.  However, it looks like you do a lot of extra work that may be
  28. ->obscuring the problem.  Why not start with a replacement for newname
  29. ->that looks like the following and see if it satisfies your needs:
  30. ->
  31. ->char *newname(char *s)
  32. ->{
  33. ->
  34. ->    char *dot;
  35. ->    dot = strchr(s, '.');
  36. ->    if (dot)
  37. ->        *dot = '\0';
  38. ->    strcat(s, ".UPD");
  39. ->    return s;
  40. ->}
  41.  
  42. Unless I'm misssing something, this isn't going to work (safely or maybe at 
  43. all), if he passes in the same string literals.
  44.  
  45. ->>main() {
  46. ->>  printf("%s\n",newname("LONGNAME.TXT"));
  47. ->>  printf("%s\n",newname("NOEND"));
  48. ->>}
  49.  
  50. -- 
  51. John R Buchan           -:|:-     Looking for that elusive FAQ?  ftp to:
  52. jatmon@mail.iag.net     -:|:-     rtfm.mit.edu /pub/usenet-by-group/....
  53.  
  54.